package com.guess.study.designpattern.factory.factorymethod.reflect.factory;

import com.guess.study.designpattern.factory.factorymethod.product.Product;

/**
 * Created by tianran on 2019-06-10.
 */
public class ConcreteCreator implements Creator {
    @Override
    public <T extends Product> T createProduct(Class<T> clazz) {
        Product product = null;
        try {
            product = (Product) Class.forName(clazz.getName()).newInstance();
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        return (T) product;
    }
}
